package com.yunfeisoft.business.model;

import com.applet.base.ServiceModel;
import org.joda.time.DateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: SmsFlashPromotion
 * Description: 限时购表
 *
 * @Author: Jackie liu
 * Date: 2020-06-02
 */
@Entity
@Table(name = "SMS_FLASH_PROMOTION")
public class SmsFlashPromotion extends ServiceModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 标题
     */
    @Column
    private String title;

    /**
     * 开始日期
     */
    @Column
    private Date startDate;

    /**
     * 结束日期
     */
    @Column
    private Date endDate;

    /**
     * 活动状态
     */
    @Column
    private Integer status;

    /**
     * 上下线状态
     */
    @Column
    private Integer onlineStatus;

    public String getStatusStr() {
        return FlashPromotionStatusEnum.valueOf(status);
    }
    
    public String getStartDateStr() {
        if (startDate != null) {
            return new DateTime(startDate).toString("yyyy-MM-dd");
        }
        return null;
    }

    public String getEndDateStr() {
        if (endDate != null) {
            return new DateTime(endDate).toString("yyyy-MM-dd");
        }
        return null;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getOnlineStatus() {
        return onlineStatus;
    }

    public void setOnlineStatus(Integer onlineStatus) {
        this.onlineStatus = onlineStatus;
    }

    public enum FlashPromotionStatusEnum {

        NOT_STARTED(1, "未开始"),
        IN_PROGRESS(2, "进行中"),
        FINISHED(2, "已结束");

        private int value;
        private String label;

        private FlashPromotionStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (FlashPromotionStatusEnum loop : FlashPromotionStatusEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }

}